﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Imaginecup.recycling.Object.Entity;
using Imaginecup.gameState.recycling.Sprite.Behavior;
using Imaginecup.Recycling.GameMan;

namespace Imaginecup.gameState.recycling.Sprite
{
    public class ToggleSprite : ISprite, IButton
    {
        private String m_TextureName;
        private ObjectInfo m_SpriteInfo;
        private Button_State m_CurrentBtnState;

        public ToggleSprite( ObjectInfo spriteInfo, String textureName)
        {
            m_SpriteInfo = spriteInfo;
            m_TextureName = textureName;
        }

        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            Texture2D texture = ResourceManager.GetInstance().GetContent(m_TextureName);
            spriteBatch.Begin();

            spriteBatch.Draw(texture,
                m_SpriteInfo.WorldLocation,
                new Rectangle(GetBtnStateByInteger() * m_SpriteInfo.FrameWidth, 0, m_SpriteInfo.FrameWidth, m_SpriteInfo.FrameHeight),
                Color.White);

            spriteBatch.End();
        }

        public void SetButtonState(Button_State state)
        {
            m_CurrentBtnState = state;
        }

        public int GetBtnStateByInteger()
        {
            int num = 0;
            switch(m_CurrentBtnState)
            {
                case Button_State.NONE:
                    num = 0;
                    break;
                case Button_State.PRESSED:
                    num = 1;
                    break;
            }
            return num;
        }


        public Button_State GetButtonState()
        {
            return m_CurrentBtnState;
        }


        public ObjectInfo GetInfo()
        {
            return m_SpriteInfo;
        }
    }
}
